package com.wwl.cms.utils.designModeTest;

/**
 * @author wwl
 * @version 1.0
 * @date 2021/8/31 20:49
 * @description:依赖倒转原则
 */
public class DependenceInversion {
    public static void main(String[] args) {
       Person person = new Person();
        person.receive(new Email());
        person.receive(new WeiXin());
    }
}
//定义接口
interface IReceiver{
    public String getInfo();
}

class Email implements IReceiver{
    public String getInfo(){
        return "电子邮件信息：hello,world";
    }
}

class WeiXin implements IReceiver{
    public String getInfo(){
        return "微信信息：hello,world";
    }
}
class Person{
    public void receive(IReceiver iReceiver){
        System.out.println(iReceiver.getInfo());
    }
}
